package com.edu.exam.enums.curriculum.questionbank;

/**
 * 难度级别枚举
 *
 * 试题难度级别定义
 *
 * @author System
 * @version 1.0.0
 */
public enum Difficulty {
    EASY("EASY", "简单"),
    MEDIUM("MEDIUM", "中等"),
    HARD("HARD", "困难");

    private final String code;
    private final String description;

    Difficulty(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    /**
     * 根据代码获取枚举值
     *
     * @param code 代码
     * @return 对应的枚举值
     */
    public static Difficulty fromCode(String code) {
        for (Difficulty difficulty : values()) {
            if (difficulty.getCode().equals(code)) {
                return difficulty;
            }
        }
        return MEDIUM; // 默认值
    }
}